colorAdminApp.controller('assigneeProcessTaskController', function($scope,$cookieStore,$compile,$rootScope,$http,$state,$stateParams,modalService) {
	
	$scope.access_token=$cookieStore.get("access_token");
	
	$scope.easyNgPagination={
			options:{
				        currentPage:1,
				        totalCount:0,
				        pageSize:10,
			            onPageChange: function(){
			 		            	$scope.loadData();
			            }
			}
	};
	
	$scope.items=[];
	$scope.q={"taskAssignee":"","processDefinitionName":""}
	$scope.loadData=function(){
		var currentPage=$scope.easyNgPagination.options.currentPage-1;
		var entity={"page":currentPage,"size":$scope.easyNgPagination.options.pageSize};
		
		entity["processDefinitionName"]=$scope.q.processDefinitionName;
		
        $(".dataTables_wrapper").block({ message:'正在加载数据，请稍等...',css: { top: '50%' } });
		$http.post('api/workflow/process/task/findForAssigneeByPage',{params:entity}).success(function(data, status, headers, config) {
			$scope.items=data.data.content;
			$scope.easyNgPagination.options.totalCount=data.data.totalElements;
			$(".dataTables_wrapper").unblock();
		}).error(function(data, status, headers, config) {
	    	
        });  
	};
	
    $scope.showFlowChart=function(entity){
       	$scope.entity=entity;
    	$("#flowChartModal").modal("show");
	};
	
	
	$scope.goComplete=function(item){
		//formKey是流程定义里开始任务属性中设置的
		var stateCode="main."+item.formKey.toUpperCase();
		//跳转页面，并传递流程定义ID
		$state.go(stateCode,{"id":item.id});	
	};
	
	 $scope.showDelegateModal=function(item){
	     $scope.id=item.id;
	    $("#delegateModal").modal("show");
	 };
	 
	 
	 
	 $scope.taskDelegate=function(userId){
			
			if(userId==""){
				alert("用户名不能为空！");return;
			}
		
			var entity={};
			entity["userId"]=userId;
			entity["id"]=$scope.id;
	    	$http.post('api/workflow/process/task/delegate',{params:entity}).success(function(data, status, headers, config) {
	    		$("#delegateModal").modal("hide");
	    		$("body").unblock();
	       		modalService.showAlertModal('注意',data.message);
	    		if(data.status==1){
	    			$scope.loadData();
	    		}
			}).error(function(data, status, headers, config) {
				$("body").unblock();
	       });  
		};
		
    
	
});
